package jeeobserver.server;

import java.io.Serializable;
import java.util.Date;

public abstract class JvmParameters implements Serializable, RequestParameter {

	private final Integer elementId;

	private final String context;

	JvmParameters(Integer elementId, String context) {
		this.elementId = elementId;
		this.context = context;
	}

	public Integer getElementId() {
		return elementId;
	}

	public String getContext() {
		return context;
	}

	public static abstract class StatisticsParameter extends JvmParameters {

		private final Date dateFrom;

		private final Date dateTo;

		StatisticsParameter(Integer elementId, String context, Date dateFrom, Date dateTo) {
			super(elementId, context);
			this.dateFrom = dateFrom;
			this.dateTo = dateTo;
		}

		public Date getDateFrom() {
			return dateFrom;
		}

		public Date getDateTo() {
			return dateTo;
		}
	}

	public static class DeleteStatisticsParameter extends StatisticsParameter {

		private static final long serialVersionUID = 40L;

		public DeleteStatisticsParameter(Date dateFrom, Date dateTo) {
			super(null, null, dateFrom, dateTo);
		}

		public DeleteStatisticsParameter(String context, Date dateFrom, Date dateTo) {
			super(null, context, dateFrom, dateTo);
		}

		public DeleteStatisticsParameter(Integer elementId, Date dateFrom, Date dateTo) {
			super(elementId, null, dateFrom, dateTo);
		}
	}

	public static class SearchStatisticsParameter extends StatisticsParameter {

		private static final long serialVersionUID = 40L;

		/** The sampling period. */
		private final int samplingPeriod;

		/** The group by. */
		private final int groupBy;

		public SearchStatisticsParameter(Integer elementId, Date dateFrom, Date dateTo, int groupBy, int samplingPeriod) {
			super(elementId, null, dateFrom, dateTo);
			this.groupBy = groupBy;
			this.samplingPeriod = samplingPeriod;
		}

		public SearchStatisticsParameter(String context, Date dateFrom, Date dateTo, int groupBy, int samplingPeriod) {
			super(null, context, dateFrom, dateTo);
			this.groupBy = groupBy;
			this.samplingPeriod = samplingPeriod;
		}

		public int getSamplingPeriod() {
			return samplingPeriod;
		}

		public int getGroupBy() {
			return groupBy;
		}
	}

	public static class SearchElementsParameter extends JvmParameters {

		private static final long serialVersionUID = 40L;

		public SearchElementsParameter(Integer elementId, String context) {
			super(elementId, context);
		}

		public SearchElementsParameter() {
			super(null, null);
		}

		public SearchElementsParameter(String context) {
			super(null, context);
		}

		public SearchElementsParameter(Integer elementId) {
			super(elementId, null);
		}
	}
}
